import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/login',
    meta: { title: '登录', noCache: true },
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/userIndex',
    component: Layout,
    redirect: '/user/center',
    hidden: true,
    children: [
      {
        path: '/user/center',
        component: (resolve) => require(['@/views/system/user/center'], resolve),
        name: 'usercenter',
        meta: { title: '个人信息', icon: 'index', affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/',
    meta: { title: '我的作品', icon: 'index', affix: true, noCache: true },
    component: Layout,
    redirect: '/myWorkList',
    children: [
      {
        path: '/myWorkList',
        component: (resolve) => require(['@/views/contentDelivery/myWork/index'], resolve),
        name: 'myWorkList',
        meta: { title: '作品列表', icon: require('@/assets/images/myWork.png'),iconShow:require('@/assets/images/myWorkShow.png'), affix: true, noCache: true }
      },
        {
        path: '/articleDetails',
        hidden: true,
        component: (resolve) => require(['@/views/contentDelivery/myWork/articleDetails'], resolve),
        name: 'articleDetails',
        meta: { title: '作品文章详情', icon: 'index', affix: true, noCache: true }
      },
        {
        path: '/videoDetails',
        hidden: true,
        component: (resolve) => require(['@/views/contentDelivery/myWork/videoDetails'], resolve),
        name: 'videoDetails',
        meta: { title: '作品视频详情', icon: 'index', affix: true, noCache: true }
      },
    ]
  },
  {
    path: '/article',
    meta: { title: '文章', keepAlive: true, icon: require('@/assets/images/article.png'), iconShow:require('@/assets/images/articleShow.png'), affix: true, noCache: true },
    component: Layout,
    redirect: '/articleRelease',
    children: [
      {
        path: '/articleRelease',
        component: (resolve) => require(['@/views/contentDelivery/articleRelease/index'], resolve),
        name: 'articleRelease',
        meta: { title: '文章发布', keepAlive: true, icon: require('@/assets/images/article.png'), iconShow:require('@/assets/images/articleShow.png'), affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/video',
    meta: { title: '视频',  keepAlive: true,  icon:  require('@/assets/images/video.png'), iconShow:require('@/assets/images/videoShow.png'), affix: true, noCache: true },
    component: Layout,
    redirect: '/videoRelease',
    children: [
      {
        path: '/videoRelease',
        component: (resolve) => require(['@/views/contentDelivery/videoRelease/index'], resolve),
        name: 'videoRelease',
        meta: { title: '视频发布', keepAlive: true, icon:  require('@/assets/images/video.png'), iconShow:require('@/assets/images/videoShow.png'),affix: true, noCache: true }
      }
    ]
  },
    {
    path: '/draftsIndex',
    meta: { title: '草稿', icon: 'index', affix: true, noCache: true },
    component: Layout,
    redirect: '/draftsList',
    children: [
      {
        path: '/draftsList',
        component: (resolve) => require(['@/views/contentDelivery/drafts/index'], resolve),
        name: 'drafts',
        meta: { title: '草稿箱', icon: require('@/assets/images/drafts.png'), iconShow:require('@/assets/images/draftsShow.png'), affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'center',
        component: (resolve) => require(['@/views/system/user/center'], resolve),
        name: '个人中心',
        meta: { title: '个人中心' }
      }
    ]
  }
]

export default new Router({
  mode: 'hash',
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
